-
Notifications
You must be signed in to change notification settings - Fork 1k
STM32F1 merged (replaced by #61) #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I will pull to my local repo and test later |
There are merge conflicts cores/arduino/stm32/analog.c Looking at interrupt.c, I don't know why it can't do an auto merge, it looks like you added the line UNUSED(port); and git doesnt like that In analog.c its this
So in one place you have NP and you changed it to NC This looks like more than a typo. Should it say NP ? |
Right Roger, |
OK I'll manually update, but I think you need to change interrupt.c as then it will auto merge when frederic merges it analog.c I think frederic will need to manually merge |
boards.txt
Outdated
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE' | ||
#To enable Serial2 (USART2 on PA3, PA2) add -DENABLE_SERIAL2 | ||
#To enable Serial3 (USART3 on PB11, PB10) add -DENABLE_SERIAL3 | ||
Other_board.menu.Other_board.BLUEPILL_F103C8.build.extra_flags=-DSTM32F103xB {build.usb_flags} {build.upload_flags} -DUSBCON "-I{build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src" "-I{build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra include path should be added to platform.txt
boards.txt
Outdated
#To enable HID (keyboard and mouse support) add also '-DUSBD_USE_HID_COMPOSITE' | ||
#To enable Serial2 (USART2 on PA3, PA2) add -DENABLE_SERIAL2 | ||
#To enable Serial3 (USART3 on PB11, PB10) add -DENABLE_SERIAL3 | ||
Other_board.menu.Other_board.MAPLEMINI_F103CB.build.extra_flags=-DSTM32F103xB {build.usb_flags} {build.upload_flags} -DUSBCON "-I{build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src" "-I{build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
cores/arduino/stm32/analog.c
Outdated
@@ -552,16 +558,22 @@ uint16_t adc_read_value(PinName pin) | |||
|
|||
if (AdcHandle.Instance == NC) return 0; | |||
|
|||
#ifndef STM32F1xx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a reordering of fields coul allow to have only on block define under STM32F1xx switch?
cores/arduino/stm32/stm32_def.h
Outdated
@@ -53,7 +53,10 @@ | |||
#define I2C1_EV_IRQn I2C1_IRQn | |||
|
|||
#elif defined(STM32F1xx) | |||
|
|||
#define DAC1 DAC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this define and replace DAC1 in the const PinMap PinMap_DAC[]
PeripheralPins.c by DAC
cores/arduino/stm32/stm32_def.h
Outdated
@@ -53,7 +53,10 @@ | |||
#define I2C1_EV_IRQn I2C1_IRQn | |||
|
|||
#elif defined(STM32F1xx) | |||
|
|||
#define DAC1 DAC | |||
#define TIM15_IRQn TIM1_BRK_TIM15_IRQn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those definitions should be moved to timer.h
https://github.com/stm32duino/Arduino_Core_STM32/blob/master/cores/arduino/stm32/timer.h#L129
Only add STM32F1xx for those 3 timers IRQ
//*** DAC *** | ||
|
||
const PinMap PinMap_DAC[] = { | ||
{NC, NC, 0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete empty arry
// {PB0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 | ||
{PB1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 | ||
// {PB1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 | ||
{NC, NC, 0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All
{NC, NC, 0}
have to be replace by
{NC, NP, 0}
{PC3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 | ||
{PC4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 | ||
{PC5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 | ||
{NC, NC, 0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All
{NC, NC, 0}
have to be replaced by
{NC, NP, 0}
// {PB0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 | ||
{PB1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 | ||
// {PB1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 | ||
{NC, NC, 0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All
{NC, NC, 0}
have to be replaced by
{NC, NP, 0}
// {PC4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 | ||
{PC5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 | ||
// {PC5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 | ||
{NC, NC, 0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All
{NC, NC, 0}
have to be replaced by
{NC, NP, 0}
I think USB CDC could be more generic and available for other variant which support it. I will do this stuff later. currently, I think we could kept this as it is. |
@rogerclarkmelbourne , |
One thing I noticed, because you have the BluePill and the Maple mini via a sub menu, and then have all the same upload options or both, You end up with the original maple mini bootloader upload as the default option. But that version of the bootloader is not available for the Blue Pill, so by default it won't work. BTW. I have tied contacting one of the manufacturers in china who make a maple mini clone (Baite Online Store), to say they should use the new bootloader and also all their links to Leaflabs are now out of date. But they have not been very communicative, so I don't expect they will change this :-( |
D:\Documents\Arduino\hardware\stm32duino\Arduino_Core_STM32\variants\MAPLEMINI_F103CB/variant.h:19:0: error: unterminated #ifndef #ifndef VARIANT_ARDUINO_STM32 Edit, My local copy may be out of date, I'm going to delete it and clone from github again |
@@ -45,7 +45,6 @@ | |||
/* Private macro -------------------------------------------------------------*/ | |||
/* Private variables ---------------------------------------------------------*/ | |||
PCD_HandleTypeDef hpcd_USB_FS; | |||
void Error_Handler(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To a future enhancement, maybe it should be fine to add one.
Native USB doesn't seem to work on a BLUEPILL-F103C8. It fails to enumerate. I get this message:
Using the same hardware it works fine with the libmaple core:
I'm running ubuntu 16.04 lts, the device is actually a red pill (same as blue pill except it has the appropriate 1k5 pull up on PA12 from the manufacturer). The device is plugged into a USB 2.0 powered hub. Native USB has never been a problem on this device. It works properly with STM32CUBEMX configured as a CDC USB device. As it does with libopencm3 acting as a BMP programming device. And finally as I already mentioned libmaple CDC works fine. Compiled for STLINK upload. |
For the BLUEPILL-F103C8 how did you decide to map the pins? They don't match the way the pins are laid out nor do they match the original libmaple simple scheme. |
@RickKimball I reordered the pin mapping of the BluePill following the old variant.h from the repository STM32F1. I don't know why I didn't copy it before. I found my BluePill board so I will check the Native USB. |
Regarding the USB not working. The BLUEPILL boards don't actually have a USB_DISC_PIN. To simulate a USB reset sequence, we have been setting the USBD+ pinmode to an output, setting the pin low, delaying for the usb reset period then setting the mode back to an input so that the pull up resistor pulls the pin high. Then the nomal USB init sequence is run. The code as written seems to expect a real USB_DISC_PIN that would have an NPN transistor. The BLUE PILL does not have any hardware like that. Sample of what you might do
|
I recently had to make a change about this in libmaple USB_DISC port and pin were defined in board.txt and passed as defined to the compiler. So I changed the code so that if either of these were null, the code to init and toggle this pin were not executed. There is a separate define in LibMaple which is also used to toggle USBD+, but I should probably change it, so that the define for USB_DISC port or pin being null is used instead This does also assume that USB_SERIAL is defined (so that the code knows that USB serial should be compiled in) |
excuse the intrusion, but i'm here only for remember that Bluepill is the most important variant for the success of this core. |
--- a/system/STM32F1xx/system_stm32f1xx.c
+++ b/system/STM32F1xx/system_stm32f1xx.c
@@ -110,8 +110,10 @@
/*!< Uncomment the following line if you need to relocate your vector Table in
Internal SRAM. */
/* #define VECT_TAB_SRAM */
+#ifndef VECT_TAB_OFFSET
#define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field.
This value must be a multiple of 0x200. */
+#endif
void USB_LP_CAN1_RX0_IRQHandler(void) {
HAL_PCD_IRQHandler(&hpcd_USB_FS);
} |
I thought we had already added bootloader uploads to the old F1 repo. One of the files ( headers ) in the HAL had to be mofied, as it did not allow overriding of the vector table offset, but this may have been fixed in newer versions of the Cube, because I know that the Cube HAL files for some other MCUs ,e g the F4 did not need to be modified as they already had the guard , ifdefs around the vector table define. The linker also needs to be changed to support using the bootloader |
This gets it to enumerate, thanks! Now to figure out why it isn't spewing data. ... |
Rick did you change system_stm32f1xx.c to match whats in the old F1 repo |
I didn't.I'm using it with an stlink. |
If a core include a variant this is to be functional... |
@fprwi6labs
Yes the digital pins seem to work fine:
|
Signed-off-by: fpr <[email protected]>
Upload method Bootloader, Serial and BMP added. USBSerial class added because is required by bootloader. Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: Frederic.Pillon <[email protected]>
Signed-off-by: Frederic.Pillon <[email protected]>
Remove STLink Rx/TX from Ax and comment in PinMap arrays other than UARTyx one. Signed-off-by: Frederic.Pillon <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: Frederic.Pillon <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Signed-off-by: fpr <[email protected]>
Please make further comment on this PR: #61 |
STM32F1 boards added. #20
The following variants are available:
I tested the following features only on the Nucleo board:
ADC, PWM, I2C (master & slave), SPI, UART, Servo, Tone, EEPROM
I require some help to test the other variants and especially all upload method for BluePill and MapleMini. In advance, thank you for your help.